<?php

class JsonApiController extends Controller
{
	public function actionIndex()
	{
		$this->render('index');
	}
        
        public function actionJson()
        {
            $array = array();
            
             
            if($_GET['action'] == 'User')
            {
                
                $array['page'] = '1'; 
                $array['total'] = '20'; 
                $array['count'] = '90';
                $array['records'] = '5';
                $model = User::model()->findAll(array('limit'=>$_GET['pageLimit'],'offset'=>'0','order' => $_GET['sidx'].' '.$_GET['sord']));
                $array = explode(',', $_GET['value']);
                $tempValue ='array(';
//                array_pop($array);
                foreach($array as $k)
                {
                    $tempValue .= '$v->'.$k.',';
                }
                
                $tempValue = substr($tempValue,0,-6);
                $tempValue .= ');';
                foreach($model as $k => $v)
                {
                    eval("\$str = ".$tempValue);
                    $array['rows'][$k]['id']=$v->uid;
                    $array['rows'][$k]['cell']=$str;
                }
            }
            echo json_encode($array);
        }

        // Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}